<template>
    <div>
        <table class="table">
            <tbody>
                <tr>
                    <td>编号</td>
                    <td>
                        <input type="text" disabled v-model="date.insenId">
                    </td>
                </tr>
                <tr>
                    <td>名称</td>
                    <td>
                        <input type="text" v-model="date.insenName">
                    </td>
                </tr>
                <tr>
                    <td>人数</td>
                    <td>
                        <input type="text" v-model="date.preame">
                    </td>
                </tr>
                <tr>
                    <td>描述</td>
                    <td>
                        <textarea v-model="date.miaoshu"></textarea>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td colspan="2">
                        <input type="button" value="更新" @click="update">
                    </td>
                </tr>
            </tbody>
        </table>
        <a href="/Show">返回显示列表</a>
    </div>
</template>

<script setup lang="ts">
import { ref,onMounted } from 'vue';
import { useRouter,useRoute } from 'vue-router';
import axios from 'axios';
const routher = useRouter();
const routhe = useRoute();
onMounted(()=>{
    upd()
})
const upd=()=>{
    var vid = routhe.query.id
    axios.get("https://localhost:7223/api/Insen/GetInsen",{params:{id:vid}}).then(res=>{
        date.value=res.data
    })
}
const update=()=>{
    axios.put("https://localhost:7223/api/Insen/UpdInse",date.value).then(res=>{
        if(res.data>0){
            alert("更新成功")
            routher.push({path:"/Show"})
        }
        else{
            alert("更新是比")
        }
    })
}
const date=ref({
  "insenId": 0,
  "insenName": "",
  "preame": 0,
  "miaoshu": "",
  //"creates": "2025-05-01T06:56:51.368Z",
  //"isDelete": false
})
</script>

<style scoped>

</style>